<?php

/**
 * This is the model class for table "client_background".
 *
 * The followings are the available columns in table 'client_background':
 * @property integer $id
 * @property string $cli_lastname
 * @property string $cli_firstname
 * @property string $cli_middlename
 * @property string $client_position
 * @property string $corporation_type
 * @property integer $cli_cellphone_no
 * @property integer $cli_telephone_no
 * @property string $cli_email
 * @property integer $client_contact_person_id
 *
 * The followings are the available model relations:
 * @property ClientContactPerson $clientContactPerson
 */
class ClientBackground extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return ClientBackground the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
const a = "Sole Proprietorship";
const b ="Partnership";
const c = "Corporation";
public function getCorporation_type(){
return array(
self::a=>"Sole Proprietorship",
self::b=>"Partnership",
self::c=>"Corporation"
);


}


	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'client_background';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('client_contact_person_id', 'required'),
			array('cli_cellphone_no, cli_telephone_no, client_contact_person_id', 'numerical', 'integerOnly'=>true),
			array('cli_lastname, cli_firstname, cli_middlename, client_position, cli_email', 'length', 'max'=>45),
			array('corporation_type', 'length', 'max'=>19),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, cli_lastname, cli_firstname, cli_middlename, client_position, corporation_type, cli_cellphone_no, cli_telephone_no, cli_email, client_contact_person_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'clientContactPerson' => array(self::BELONGS_TO, 'ClientContactPerson', 'client_contact_person_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'cli_lastname' => 'Cli Lastname',
			'cli_firstname' => 'Cli Firstname',
			'cli_middlename' => 'Cli Middlename',
			'client_position' => 'Client Position',
			'corporation_type' => 'Corporation Type',
			'cli_cellphone_no' => 'Cli Cellphone No',
			'cli_telephone_no' => 'Cli Telephone No',
			'cli_email' => 'Cli Email',
			'client_contact_person_id' => 'Client Contact Person',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('cli_lastname',$this->cli_lastname,true);
		$criteria->compare('cli_firstname',$this->cli_firstname,true);
		$criteria->compare('cli_middlename',$this->cli_middlename,true);
		$criteria->compare('client_position',$this->client_position,true);
		$criteria->compare('corporation_type',$this->corporation_type,true);
		$criteria->compare('cli_cellphone_no',$this->cli_cellphone_no);
		$criteria->compare('cli_telephone_no',$this->cli_telephone_no);
		$criteria->compare('cli_email',$this->cli_email,true);
		$criteria->compare('client_contact_person_id',$this->client_contact_person_id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}